package secretaryGUI;

import java.awt.Color;

import flexibility.DatePicker;
import gui.secretaryScreen;
import guiCode.secretaryScreenCode;

public class planNextSemester {
	secretaryScreenCode ssc;
	secretaryAlerts sa = new secretaryAlerts();
	
	public void buttonClick(secretaryScreenCode code, createSecretaryWindow csw) {
		ssc = code;
		if (csw.btnPlanNextSemester.getText().equals("Plan next semester")) {
			ssc.setSemesterForEditing(1);// this is the code for the
											// next semester
			csw.btnPlanNextSemester.setText("Quit next semester planning");
			csw.alertsLbl.setText("Click on 'View existing classes' to view all the classes in this semester\n" +
					"Click on 'View courses' to see all the courses in this semester, add and remvoe courses from this semester");
			csw.btnViewCourses.setEnabled(true);
			csw.btnPlanNextSemester.setForeground(Color.RED);
			csw.btnEditCurrentSemester.setEnabled(false);
			csw.btnActivateNewSemester.setEnabled(false);
			csw.btnViewPreviousSemester.setEnabled(false);
			csw.btnViewExistingClasses.setEnabled(true);

			if (ssc.isOpenSemester(1) == false) {// there is no open
				csw.calendar = new DatePicker(csw.secretaryScreen); // semester
				String date = csw.calendar.setPickedDate();
				if (date.equals("") == true) {// this is just empty date
												// check
					sa.showMessages(csw,ssc,csw.secretaryScreen,"No date was selected!", "Date Error", 1);
					
				} else {// date is valid
					sa.showMessages(csw, ssc, csw.secretaryScreen,"Next semester will begin at "
							+ csw.calendar.setPickedDate() + " . Are you sure?",
							"Next semester begin date confirmation", 2);
				}
			}
		} else if (csw.btnPlanNextSemester.getText().equals(
				"Quit next semester planning")) {
			csw.alertsLbl.setText("");
			csw.lblUP.setText("");
			ssc.backToDefault(csw,ssc);
			csw.btnViewCourses.setEnabled(false);
			csw.btnViewCourses.setText("View courses");
			csw.btnViewCourses.setForeground(Color.BLACK);
			csw.btnAssignCourseTo.setEnabled(false);
			csw.btnRemoveCourseFrom.setEnabled(false);
			csw.btnPlanNextSemester.setText("Plan next semester");
			csw.btnEditExistingClass.setText("Edit existing class");
			csw.btnEditExistingClass.setForeground(Color.BLACK);
			csw.btnRemoveStudentFrom.setEnabled(false);
			csw.btnAddStudentTo.setEnabled(false);
			csw.btnPlanNextSemester.setForeground(Color.BLACK);
			ssc.setSemesterForEditing(-1);// this is the code for no
											// semester selected
			csw.btnEditCurrentSemester.setEnabled(true);
			csw.btnActivateNewSemester.setEnabled(true);
			csw.btnViewPreviousSemester.setEnabled(true);
			csw.btnRemoveStudentFrom.setEnabled(false);
			csw.btnAddStudentTo.setEnabled(false);
			csw.btnViewExistingClasses.setEnabled(false);
			csw.btnEditExistingClass.setEnabled(false);
			csw.btnCreateNewClass.setEnabled(false);
			if (ssc.checkForCurrentSemester()) {
				csw.btnEditCurrentSemester.setEnabled(true);
			} else {
				csw.btnEditCurrentSemester.setEnabled(false);
			}
		}
	}
}
